vcpkg_from_github(
        OUT_SOURCE_PATH SOURCE_PATH
        REPO libsdl-org/SDL_mixer
        REF "b3a6fa8b5ad183f0a1bad02527d89a00c3c90106"
        SHA512 dc75161ae71c697fc66885394448b171fa1cce73d3ff85d0d87699b0da2985128a55eca55cf15701776d986ac4738bb8678cfe6f6cba41a0471c8b529b3b33d0
        HEAD_REF main
)

# 特性选项映射（注意前缀统一为 SDLMIXER_）
vcpkg_check_features(
    OUT_FEATURE_OPTIONS FEATURE_OPTIONS
    FEATURES
        fluidsynth SDLMIXER_MIDI
        fluidsynth SDLMIXER_MIDI_FLUIDSYNTH
        libflac SDLMIXER_FLAC
        libflac SDLMIXER_FLAC_LIBFLAC
        mpg123 SDLMIXER_MP3
        mpg123 SDLMIXER_MP3_MPG123
        wavpack SDLMIXER_WAVPACK
        wavpack SDLMIXER_WAVPACK_DSD
        opusfile SDLMIXER_OPUS
)

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED)

vcpkg_cmake_configure(
    SOURCE_PATH "${SOURCE_PATH}"
    OPTIONS
        ${FEATURE_OPTIONS}
        -DSDLMIXER_VENDORED=OFF
        -DSDLMIXER_SAMPLES=OFF
        -DSDLMIXER_DEPS_SHARED=OFF
        -DSDLMIXER_OPUS_SHARED=OFF
        -DSDLMIXER_VORBIS=VORBISFILE
        -DSDLMIXER_FLAC_DRFLAC=OFF
        -DSDLMIXER_MOD_XMP_SHARED=${BUILD_SHARED}
        -DSDLMIXER_MIDI_NATIVE=OFF
        -DSDLMIXER_MIDI_TIMIDITY=OFF
        -DSDLMIXER_MP3_DRMP3=OFF
    MAYBE_UNUSED_VARIABLES
        SDLMIXER_MP3_DRMP3
)

vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup(PACKAGE_NAME "SDL3_mixer" CONFIG_PATH "cmake")
vcpkg_fixup_pkgconfig()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")